<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('评委列表')" />
    <th:block th:include="include :: layout-latest-css" />
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <!-- 搜索区域：评委相关搜索项 -->
            <div class="col-sm-12 search-collapse">
                <form id="juror-form">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                登录名称：<input type="text" name="loginName"/>-->
<!--                            </li>-->
                            <li>
                                评委姓名：<input type="text" name="userName"/>
                            </li>
<!--                            <li>-->
<!--                                身份类型：-->
<!--                                <select name="identity">-->
<!--                                    <option value="">全部</option>-->
<!--                                    <option value="学生评委">学生评委</option>-->
<!--                                    <option value="教师评委">教师评委</option>-->
<!--                                </select>-->
<!--                            </li>-->
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!-- 操作按钮栏：评委相关权限 -->
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:juror:add">
                    <i class="fa fa-plus"></i> 新增评委
                </a>
<!--                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()" shiro:hasPermission="system:juror:edit">-->
<!--                    <i class="fa fa-edit"></i> 修改-->
<!--                </a>-->
<!--                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:juror:remove">-->
<!--                    <i class="fa fa-remove"></i> 移除-->
<!--                </a>-->
                <!-- 可根据需求添加导入、导出等按钮 -->
            </div>

            <!-- 评委列表表格：匹配评委字段 -->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js" />
<script th:inline="javascript">
    // 评委权限标识
    var editFlag = [[${@permission.hasPermi('system:juror:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:juror:remove')}]];
    var prefix = ctx + "comp/juror"; // 评委接口前缀

    $(function() {
        if ($(this).width() < 769) {
            $('.search-collapse').addClass('collapsed');
        }
        if ($.fn.toTop !== undefined) {
            var opt = {
                win:$('.ui-layout-center'),
                doc:$('.ui-layout-center')
            };
            $('#scroll-up').toTop(opt);
        }
        queryJurorList(); // 加载评委列表
    });

    // 加载评委列表：配置表格列与接口
    function queryJurorList() {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            modalName: "评委",
            columns: [{
                checkbox: true
            },
                {
                    field: 'userId',
                    title: '评委ID',
                    visible: false
                },
                {
                    field: 'userName',
                    title: '评委信息',
                    formatter: function(value, row, index) {
                        return '<div><strong>' + value + '</strong></div>' +
                            '<div>ID: ' + row.userId + '</div>' +
                            '<div>账号: ' + row.loginName + '</div>';
                    }
                },
                {
                    field: 'identity',
                    title: '身份',
                    formatter: function(value, row, index) {
                        var userType = "";
                        var color = "info";
                        if (row.userType == '00') {
                            color = "primary";
                            userType = "超级管理员"
                        } else if(row.userType == '01'){
                            color = "success";
                            userType = "管理员";
                        } else if(row.userType == '02'){
                            color = "info";
                            userType = "普通客户";
                        } else if(row.userType == '03'){
                            color = "info";
                            userType = "学生评委";
                        } else if(row.userType == '04'){
                            color = "info";
                            userType = "教师评委";
                        }

                        return '<span class="label label-' + color + '">' + userType + '</span>';
                    }

                },
                {
                    field: 'scoreCount',
                    title: '评分记录',
                    formatter: function(value, row, index) {
                        return value + '次评分<br/>' +
                            '<a href="javascript:void(0)" onclick="viewScoreRecord(' + row.userId + ')">查看记录</a>';
                    }
                },
                {
                    field: 'lastScoreTime',
                    title: '最近评分时间'
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return value === "0" ?
                            '<span class="label label-success">已绑定</span>' :
                            '<span class="label label-danger">已禁用</span>';
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.userId + '\')"><i class="fa fa-trash"></i>移除</a> ');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    }

    // 查看评分记录（示例方法，需后端配合接口）
    function viewScoreRecord(userId) {
        var url = prefix + "/scoreRecord/" + userId;
        $.modal.openTab("评分记录", url);
    }
</script>
</body>
</html>